package com.mocoop.task;


import java.util.List;

import org.json.JSONException;

import com.mocoop.activity.MocoopActivity;
import com.mocoop.dao.AjaxWorkerDao;
import com.mocoop.dao.AjaxWorkerDaoImp;
import com.mocoop.entity.AjaxInfo;
import com.mocoop.plugin.ajax.AjaxWorker;

import android.os.AsyncTask;

public class AutoRequestTask extends AsyncTask<Object, Void, Void>{
	private MocoopActivity mocoopActivity;
	
	
	public AutoRequestTask(MocoopActivity mocoopActivity) {
		super();
		this.mocoopActivity = mocoopActivity;
	}
	@Override
	protected Void doInBackground(Object... objects) {
		AjaxWorkerDao ajaxWorkerDao = new AjaxWorkerDaoImp(mocoopActivity, objects[0].toString());
		List<AjaxInfo> list = ajaxWorkerDao.findUnfinishedAjax();
		AjaxWorker ajaxWorker = new AjaxWorker(mocoopActivity,objects[0].toString());
		for (AjaxInfo ajaxInfo : list) {
			try {
				ajaxWorker.executeRequestBiz(ajaxInfo);
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	@Override
	protected void onPostExecute(Void result) {
		
	}

}
